<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "edu_video_discuss".
 *
 * @property int $id
 * @property int $course_id 课程id
 * @property int $evaluate_id 课程下某条评论的id
 * @property int $reply_user_id 评论者id
 * @property int $answer_user_id 被评论者id
 * @property string $dis_comment 评论内容
 * @property int $status 状态 默认1通过 0禁用
 * @property int $create_time 创建时间
 */
class EduVideoDiscuss extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'edu_video_discuss';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['course_id', 'evaluate_id', 'reply_user_id', 'create_time'], 'required'],
            [['course_id', 'evaluate_id', 'reply_user_id', 'answer_user_id', 'status', 'create_time'], 'integer'],
            [['dis_comment'], 'string', 'max' => 500],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'course_id' => '课程 ID',
            'evaluate_id' => '课程下评论 ID',
            'reply_user_id' => '评论者 ID',
            'answer_user_id' => '被评论者 ID',
            'dis_comment' => '评论内容',
            'status' => '状态',
            'create_time' => '时间',
        ];
    }

    /**
     * 跟课程关联
     * @return \yii\db\ActiveQuery
     */
    public function getVideo()
    {
        return $this->hasOne(EduVideoCourse::class, ['id' => 'course_id']);
    }

    /**
     * 跟edu_user关联
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(EduUser::class, ['id' => 'reply_user_id']);
    }

    /**
     * 跟用户edu_user关联
     * @return \yii\db\ActiveQuery
     */
    public function getWasUser()
    {
        return $this->hasOne(EduUser::class, ['id' => 'answer_user_id']);
    }
}
